<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/jsp/taglibs.jsp"%>
<%
	String menuId = request.getAttribute("menuId") == null ? "":request.getAttribute("menuId").toString();
	String message = request.getAttribute("message") == null ? "":request.getAttribute("message").toString();
	String parentId = request.getAttribute("parentId") == null ? "":request.getAttribute("parentId").toString();
	String isLeaf = request.getAttribute("isLeaf") == null ? "":request.getAttribute("isLeaf").toString();
	String styleFlag = request.getAttribute("styleFlag") == null ? "":request.getAttribute("styleFlag").toString();
	String url = request.getAttribute("url") == null ? "":request.getAttribute("url").toString();
	String menuname = request.getAttribute("menuname") == null ? "":request.getAttribute("menuname").toString();
	String level = request.getAttribute("level") == null ? "":request.getAttribute("level").toString();
	String link = request.getAttribute("link") == null ? "":request.getAttribute("link").toString();
	String treeShow = request.getAttribute("treeShow") == null ? "":request.getAttribute("treeShow").toString();
	String root = request.getAttribute("root") == null ? "":request.getAttribute("root").toString();
	String rootId = request.getAttribute("rootId") == null ? "":request.getAttribute("rootId").toString();
	String rootName = request.getAttribute("rootName") == null ? "":request.getAttribute("rootName").toString();
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title>menu content</title>
<link id="editCss" rel="stylesheet" type="text/css" href="<%=basePath %>css/style.css" />
<link id="rightCss" rel="stylesheet" type="text/css" href="<%=basePath %>css/right.css" />
<link id="dtreeCss" rel="stylesheet" type="text/css" href="<%=basePath %>css/dtree.css" />
<style>
html,body { height:100%; overflow:hidden;}
</style>
<script type="text/javascript">
	function submitForm(type,add){
		
		document.getElementById("opType").value=type;
		document.getElementById("addType").value=add;
		
		if(checkMenuName()) {
			document.menu.submit();
		}
	}
	
	function checkMenuName(){
		var name = document.getElementById('menuname').value;
		if(name == ""){
			alert('菜单名称不能为空!');
			return false;
		}
		//if(name.length > 8) {
		//	alert('字数不能超过8个!');
		//	return false;
		//}
		
		var parentId = document.getElementById('parentId').value;
		var styleFlag = document.getElementById('styleFlag').value;
		if(parentId == "0" && styleFlag == "1"){
			alert('增同一级菜单,必须为水平显示!');
			return false;
		}
		return true;
	}
</script>

<script type="text/javascript" src="<%=basePath %>js/menu_dtree.js"></script>
</head>
<body class="bgpic">
<div class="crumbs">
	当前位置： <%=link %>
</div>
<table border="0" cellpadding="0" cellspacing="0" width="100%"  height="100%">
<tr>
<% if(!treeShow.equals("")) { %>
	  <td width="280" valign="top" style=" _height:100%; bottom:0;">
		<div style="width:280px; position:absolute; top:26px; right:0px; left:0px; bottom:0px;  overflow: auto; height:94%; vertical-align: top;border: #8cb9cc 1px solid;  background-color:#FFF" id="treeDiv">
			<script type="text/javascript">
				var d = new dTree('d','<%=basePath %>',document);
				d.add("<%=rootId %>", -1, "<%=rootName %>","1","竖直显示"); 
			</script>
			
			<c:forEach items="${treeList}" var="tree" varStatus="i">
				<script type="text/javascript">
						d.add('${tree.menuId}','${tree.parentId}','${tree.menuName}','${tree.menuURL}');
				</script>
			</c:forEach>
			<script type="text/javascript">
					document.write("<br>"+d);
			</script>
		</div>
	  </td>
	   <%  }  %>
<td valign="top" height="100%">
<div class="search">
	<div class="tab">
		<span class="right"></span>
		<span class="font-blue14pxb">修改菜单</span>
	</div>
</div>	
<form id="menu" name="menu" action="<%=basePath %>servlet/menu" method="post">
	<div class="tableBox">
	  <table cellPadding="0" cellSpacing="0" border="0" width="100%" id="tableList" bgcolor="#FFFFFF">
		<tr>
		  <th class="text_right h" width="20%">菜单名称</th>
		  <td class="text_left"><input style="width:90%" type="text" id="menuname" name="menuname" value="<%=menuname %>"/></td>
		</tr>
		<tr>
		  <th class="text_right h">URL(请填写相对路径):</th>
		  <td class="text_left"><input style="width:90%" type="text" id="url" name="url" value="<%=url %>"/></td>
		</tr>
		<tr>
			<th class="text_right h">
				<input type="hidden" id="opType" name="opType" value="0"/>
				<input type="hidden" id="addType" name="addType" value="0"/>
				<input type="hidden" id="selfName" name="selfName" value="modify"/>
				<input type="hidden" id="level" name="level" value="<%=level %>"/>
				<input type="hidden" id="menuId" name="menuId" value="<%=menuId %>"/>
				<input type="hidden" id="root" name="root" value="<%=root %>"/>
				<input type="hidden" id="parentId" name="parentId" value="<%=parentId %>"/>
				显示方式:
			</th>
			<td class="text_left">
				<select id="styleFlag" name="styleFlag">
				<% if(styleFlag.equals("") || styleFlag.equals("0")) { %>
					<option value="0" selected="selected">水平显示</option>
					<option value="1">竖直显示</option>
				<% } else if(styleFlag.equals("1")) {  %>
					<option value="0">水平显示</option>
					<option value="1" selected="selected">竖直显示</option>
				<% } %>
				</select>
			</td>
		</tr>
		<!-- 
		<tr>
		  <th class="text_right h">是否为叶子节点:</th>
		  <td class="text_left">
	  		<% //if(isLeaf.equals("")) { %>
	  			<input type="hidden" id="isLeaf" name="isLeaf" readonly value="1"/>
				<input type="text" id="leaf" name="leaf" readonly value="是"/>
			<% //} else if(isLeaf.equals("0")) { %>
				<input type="hidden" id="isLeaf" name="isLeaf" readonly value="0"/>
				<input type="text" id="leaf" name="leaf" readonly value="否"/>
			<% //} else if(isLeaf.equals("1")) {  %>
				<input type="hidden" id="isLeaf" name="isLeaf" readonly value="1"/>
				<input type="text" id="leaf" name="leaf" readonly value="是"/>
			<% //} %>
		  </td>
		</tr>
		 -->
		<tr class="footer">
			<td colspan="2" class="bgcolf">
				<input type="button" id="modify" name="modify" onclick="javaScript:submitForm(1,0)" value="保存" class="button"/>
				<input type="button" id="back" name="back" onclick="javaScript:history.go(-1);" value="返回" class="button"/>
			</td>
		</tr>
		<tr>
			<td colspan="2" class="bgcolf"><%=message %></td>
		</tr>
	  </table>
	</div>
</form>
</td>
</tr>
</table>
</body>
</html>